package com.sky.mapper;

import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;

public interface WorkspaceMapper {
    /**
     * 获取营业额
     * @param min
     * @param max
     * @return
     */
    @Select("select sum(amount) from orders where order_time between #{min} and #{max} and status = 5")
    Double getTurnover(LocalDateTime min, LocalDateTime max);

    /**
     * 获取有效订单
     * @param min
     * @param max
     * @return
     */
    @Select("select count(*) from orders where order_time between #{min} and #{max} and status = 5")
    Integer getValidOrderCount(LocalDateTime min, LocalDateTime max);

    /**
     * 获取所有订单
     * @param min
     * @param max
     * @return
     */
    @Select("select count(*) from orders where order_time between #{min} and #{max}")
    Integer getAllOrders(LocalDateTime min, LocalDateTime max);

    /**
     * 新增用户
     * @param min
     * @param max
     * @return
     */
    @Select("select count(*) from user where create_time between #{min} and #{max}")
    Integer newUsers(LocalDateTime min, LocalDateTime max);

    /**
     * 起售套餐数
     * @return
     */
    @Select("select count(*) from setmeal where status = 1")
    Integer sold();

    /**
     * 停售套餐数
     * @return
     */
    @Select("select count(*) from setmeal where status = 0")
    Integer discontinued();

    /**
     * 起售菜品
     * @return
     */
    @Select("select count(*) from dish where status = 0")
    Integer soldDish();
    /**
     * 停售菜品
     * @return
     */
    @Select("select count(*) from dish where status = 0")
    Integer discontinuedDish();

    /**
     * 查询订单数量
     * @return
     */
    @Select("select count(*) from orders where status = #{status}")
    Integer getOrderByStatus(Integer status);
    @Select("select count(*) from orders ")
    Integer getOrders();
}
